{extend name="public/main"}

{block name='css'}
    <link rel="stylesheet" href="__CSS__/install.css?ver={:time()}">
{/block}

{block name='body'}
    <div class="main">
        <h1>安装程序</h1>
        <form class="layui-form form-box">
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                  <input type="text" name="uid" required  lay-verify="required" placeholder="填写用户名" autocomplete="off" class="layui-input" lay-verType="tips">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">昵称</label>
                <div class="layui-input-block">
                  <input type="text" name="nick" required  lay-verify="required" placeholder="填写昵称" autocomplete="off" class="layui-input" lay-verType="tips">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                  <input type="password" name="pwd" required  lay-verify="required" placeholder="请填写密码" autocomplete="off" class="layui-input" lay-verType="tips">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">确认密码</label>
                <div class="layui-input-block">
                  <input type="password" name="pwd2" required  lay-verify="required" placeholder="再次填写密码" autocomplete="off" class="layui-input" lay-verType="tips">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block submit-box">
                  <button class="layui-btn layui-btn-normal" lay-submit lay-filter="*" id="submit">立即提交</button>
                </div>
            </div>
        </form>
    </div>
{/block}

{block name='js'}
<script>
    form.on('submit(*)', d => {
        d = d.field
        _post('/index/api/install', d, c => {
            if(c && c.code == 1) {
                _tip('安装成功', 6)
                location.href = '/'
            } else {
                _tip(c.msg || '安装失败', 5)
            }
        })
        return false
    })
</script>
{/block}